使用Docker搭建Anaconda Python3.6的练习环境

文章作者:Tyan
博客:noahsnail.com  |  CSDN  |  简书

最近在看Python 3的相关内容,由于电脑里已经装了Anaconda 2.7,因此就在Docker里搭建了一个Anaconda Python3.6的练习环境。Dockerfile如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
FROM nvidia/cuda:8.0-cudnn6-devel-ubuntu16.04
MAINTAINER Tyan <tyan.liu.git@gmail.com>


# Install basic dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
cmake \
git \
wget \
libopencv-dev \
libsnappy-dev \
python-dev \
python-pip \
tzdata \
vim


# Install anaconda for python 3.6
RUN wget --quiet https://repo.continuum.io/archive/Anaconda3-5.0.1-Linux-x86_64.sh -O ~/anaconda.sh && \
/bin/bash ~/anaconda.sh -b -p /opt/conda && \
rm ~/anaconda.sh && \
echo "export PATH=/opt/conda/bin:$PATH" >> ~/.bashrc


# Set timezone
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime


# Set locale
ENV LANG C.UTF-8 LC_ALL=C.UTF-8


# Initialize workspace
RUN mkdir /workspace
WORKDIR /workspace

构建docker image命令如下:

1
docker build -t python:3.6 .

运行docker image命令如下:

1
docker run -ti --rm python:3.6
如果有收获,可以请我喝杯咖啡!